/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package game;

import java.util.Random;
import javax.swing.Icon;
import javax.swing.ImageIcon;

/**
 *
 * @author s0920761
 */
public class Role extends Person{
    
    private int book;
    private Random p=new Random();


    public Role(String name, int money,Icon pic){

        super(name,money,pic);
    }
   

    public int get_info_book()
    {
        return book;
    }

     
    public boolean consume(int i)
    {
        if(i==0)//buy food
        {
        int cost=p.nextInt(10);
        money-=cost;

        if(money>0)
        {
            
            return true;

        }
        else
        {
            money+=cost;
            return false;
        }
        }

        else if(i==1)//buy book
        {
            if(money>=10)
        {
        book+=1;
        money-=10;
        return true;
        }
        else
            return false;

        }
        else
            return false;//
    }

   
    




}
